-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat: 添加微信小程序多端登录 code2VerifyInfo 接口支持 #3786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
本 PR 实现了微信小程序多端登录验证接口 code2VerifyInfo,用于支持手表端等多端登录场景。该实现遵循了 WxJava 项目的编码规范和架构模式,代码质量良好。
主要变更:
- 新增 API 接口支持多端登录场景(手表端授权等)
- 按照微信官方文档实现了完整的请求和响应处理
- 遵循项目现有的代码组织和命名约定
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java | 在 User 接口中新增 CODE_2_VERIFY_INFO_URL 常量,定义多端登录验证接口的 URL |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCode2VerifyInfoResult.java | 新增响应结果类,包含 session_key、openid、unionid、is_limit 四个字段,使用 Lombok 注解和 Gson 序列化 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java | 在用户服务接口中新增 getCode2VerifyInfo 方法定义,包含完整的 Javadoc 文档和参数说明 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java | 实现 getCode2VerifyInfo 方法,调用微信 API 并返回解析后的结果对象 |
| public WxMaCode2VerifyInfoResult getCode2VerifyInfo(String code, String checkcode) throws WxErrorException { | ||
| JsonObject param = new JsonObject(); | ||
| param.addProperty("code", code); | ||
| param.addProperty("checkcode", checkcode); | ||
| String responseContent = this.service.post(CODE_2_VERIFY_INFO_URL, param.toString()); | ||
| return WxMaCode2VerifyInfoResult.fromJson(responseContent); | ||
| } |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增的 getCode2VerifyInfo 方法缺少相应的单元测试。建议在 WxMaUserServiceImplTest.java 中添加测试用例,可以参考同文件中 testGetPhoneInfo() 的测试模式。
示例测试方法:
@Test
public void testGetCode2VerifyInfo() throws WxErrorException {
WxMaCode2VerifyInfoResult result = this.wxService.getUserService()
.getCode2VerifyInfo("testCode", "testCheckcode");
assertNotNull(result);
System.out.println(result.toString());
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
实现微信小程序多端登录验证接口
code2VerifyInfo,用于手表端等多端登录场景。官方文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/openapi/code2Verifyinfo.html
变更内容
CODE_2_VERIFY_INFO_URL常量session_key、openid、unionid、is_limit字段getCode2VerifyInfo(String code, String checkcode)接口方法使用示例
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.